package com.liu.netty5.client;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelHandlerInvoker;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.concurrent.EventExecutorGroup;

/**
 * Created by Administrator on 2019/9/2 0002.
 */
public class ClientHandler1 extends SimpleChannelInboundHandler<String> {




    @Override
    protected void messageReceived(ChannelHandlerContext channelHandlerContext, String s) throws Exception {
        System.out.println("客户端接收到的服务端消息为："+s);

    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        StringBuffer pic = new StringBuffer();
        pic.append("{\"id\":\"10\",\"image\":\"" );
        pic.append( "gEMh0tQghhBBCCCGETAIouBNCCCGEEEIIIYQQQgghJuDIdAUIIYQQQgghhBBCCCGEkKkABXdCCCGEEEIIIYQQQgghxARyjazU0tKSkvHOzs6UyhFCCCGEEEIIIYQQQgghk43/A5UsoImQjmtoAAAAAElFTkSuQmCC\"}");
        pic.append(System.getProperty("line.separator"));
        ctx.writeAndFlush(pic.toString());

            ctx.writeAndFlush("{\"id\":\"10\",\"image\":\"121312312\"}"+System.getProperty("line.separator"));



    }
}
